package com.woniu.dating.mapper;

import com.woniu.dating.pojo.DatingConcern;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 玖柒
 * @since 2023-05-20
 */
public interface DatingConcernMapper extends BaseMapper<DatingConcern> {

    /**
     * 查询当前用户下关注的所有人的id
     * @param userId
     * @return
     */
    @Select("select id,user_id from t_dating_concern where current_id = #{userId}")
    List<DatingConcern> listDatingConcern(Integer userId);

    /**
     * 查询当前用户是否已经关注了该用户
     * @param currentId
     * @param userId
     * @return
     */
    @Select("select id,user_id from t_dating_concern where current_id = #{currentId} and user_id = #{userId}")
    DatingConcern getDatingConcern(@Param("currentId") Integer currentId, @Param("userId") Integer userId);

    /**
     * 取消关注，删除关注信息
     * @param currentId
     * @param userId
     * @return
     */
    @Delete("delete from t_dating_concern where current_id = #{currentId} and user_id = #{userId}")
    Integer cancelConcern(@Param("currentId") Integer currentId, @Param("userId") Integer userId);
}
